diff options
| author | aman333nolawz <amananudhiu@gmail.com> | 2026-03-02 21:49:13 +0530 |
|---|---|---|
| committer | aman333nolawz <amananudhiu@gmail.com> | 2026-03-02 21:49:13 +0530 |
| commit | d41eff9eccf66644c4c60f53cb516bf079937a28 (patch) | |
| tree | 248a0863a3181369f943d678ec4273911d35efac /src/pages/authors/[...id].astro | |
Using astro-erudite for static site generation
Diffstat (limited to 'src/pages/authors/[...id].astro')
| -rw-r--r-- | src/pages/authors/[...id].astro | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/pages/authors/[...id].astro b/src/pages/authors/[...id].astro new file mode 100644 index 0000000..d71fcf8 --- /dev/null +++ b/src/pages/authors/[...id].astro @@ -0,0 +1,58 @@ +--- +import AuthorCard from '@/components/AuthorCard.astro' +import BlogCard from '@/components/BlogCard.astro' +import Breadcrumbs from '@/components/Breadcrumbs.astro' +import PageHead from '@/components/PageHead.astro' +import Layout from '@/layouts/Layout.astro' +import { getAllAuthors, getPostsByAuthor } from '@/lib/data-utils' + +export async function getStaticPaths() { + const authors = await getAllAuthors() + return authors.map((author) => ({ + params: { id: author.id }, + props: { author }, + })) +} + +const { author } = Astro.props +const authorPosts = await getPostsByAuthor(author.id) +--- + +<Layout class="max-w-3xl"> + <PageHead + slot="head" + title={`${author.data.name} (Author)`} + description={author.data.bio || `Profile of ${author.data.name}.`} + noindex + /> + <Breadcrumbs + items={[ + { href: '/authors', label: 'Authors', icon: 'lucide:users' }, + { label: author.data.name, icon: 'lucide:user' }, + ]} + /> + + <section> + <AuthorCard author={author} /> + </section> + <section class="flex flex-col gap-y-4"> + <h2 class="text-2xl font-medium">Posts by {author.data.name}</h2> + { + authorPosts.length > 0 ? ( + <ul class="flex flex-col gap-4"> + {authorPosts + .filter((post) => !post.data.draft) + .map((post) => ( + <li> + <BlogCard entry={post} /> + </li> + ))} + </ul> + ) : ( + <p class="text-muted-foreground"> + No posts available from this author. + </p> + ) + } + </section> +</Layout> |
